import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { DeepPartial, Repository } from 'typeorm';
import { TypeOrmCrudService } from '@dataui/crud-typeorm';

import { TestingMachine } from '@/testing-machine/entities/testing-machine.entity';
import { CrudRequest, GetManyDefaultResponse } from '@dataui/crud';

@Injectable()
export class TestingMachineService extends TypeOrmCrudService<TestingMachine> {
  constructor(
    @InjectRepository(TestingMachine) repo: Repository<TestingMachine>,
  ) {
    super(repo);
  }

  async getMany(
    req: CrudRequest,
  ): Promise<GetManyDefaultResponse<TestingMachine> | TestingMachine[]> {
    const result = await super.getMany(req);
    return result;
  }

  async createOne(
    req: CrudRequest,
    dto: DeepPartial<TestingMachine>,
  ): Promise<TestingMachine> {
    console.log(' I Create One!');
    const result = await super.createOne(req, dto);
    return result;
  }
}
